//
// Created by bxw57 on 2024/6/13.
//

#include <stdexcept>
#include "Sequence.h"
template<class T>
T Sq<T>::pop() {
    if (this->top == 0)
        throw std::runtime_error("Stack is empty");
    else
        return this->arr[--this->top];
}

template<class T>
void Sq<T>::push(T val) {
    if (this->top == this->cap) {
        T tmp[this->cap];
        for (int i = 0; i < this->cap; i++)
            tmp[i] = this->arr[i];
        this->cap *= 2;
        delete[] this->arr;
        this->arr = new T[this->cap];
        for (int i = 0; i < this->cap; i++)
            this->arr[i] = tmp[i];
    }
    this->arr[this->top++] = val;
}